package com.example.demo.mapper;

import java.io.IOException;

import com.example.demo.bean.FlowBean;
import com.example.demo.bean.PhoneBean;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.ObjectWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.util.StringUtils;

public class MyMapper extends Mapper<LongWritable, Text, PhoneBean, FlowBean>{
    @Override
    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, PhoneBean, FlowBean>.Context context)
            throws IOException, InterruptedException {
        String[] splited = value.toString().split("\t");
        String phone = splited[1];
        String up = splited[7];
        String down = splited[8];
        context.write(new PhoneBean(phone), new FlowBean(Long.parseLong(up), Long.parseLong(down)));
    }
}
